package com.sangu.dianxiu.adapter;

import android.content.Context;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.sangu.dianxiu.R;
import com.sangu.dianxiu.bean.repairtype.RecommendEntity;

import java.util.List;

/**
 * 首页推荐adapter，继承自AppBaseAdapter
 * Created by sg2 on 2016/1/7.
 */
public class RecommendGvAdapter extends AppBaseAdapter{
    public RecommendGvAdapter(List list, Context context) {
        super(list, context);
    }

    @Override
    public ViewHolder getViewHolder(int position, View convertView, ViewGroup parent) {
        RecommendEntity.RecommendsEntity entity= (RecommendEntity.RecommendsEntity) list.get(position);
        ViewHolder vh=ViewHolder.get(context,convertView,parent, R.layout.item_home_fragment_gv_hotrecommend);
        TextView tvHotName= (TextView) vh.findViewById(R.id.tv_fragment_home_hot_name);
        TextView tvHotContent= (TextView) vh.findViewById(R.id.tv_fragment_home_hot_content);
        ImageView iv= (ImageView) vh.findViewById(R.id.iv_home_fragment_hotrecommend);
        TextView tvVertical= (TextView) vh.findViewById(R.id.tv_line_vertical);
        TextView tvHorizontal= (TextView) vh.findViewById(R.id.tv_line_horizontal);
        tvHotName.setText(entity.getName());
        tvHotContent.setText(entity.getComment());
        iv.setImageURI(Uri.parse(entity.getImgUrl()));
        if(position%2==1)
        {
            tvVertical.setVisibility(View.GONE);            //根据位置来判断竖线是否显示，若处于屏幕的边缘，则不显示，否则应该显示
        }
        if(position==list.size()-1||position==list.size()-2)
        {
            tvHorizontal.setVisibility(View.GONE);          //根据位置来判断横线是否显示，若处于屏幕的边缘，则不显示，否则应该显示
        }
        return vh;
    }
}
